Skip to content

fix(terminal): map macOS Command+. to interrupt running command like Ctrl+C - #3409

Merged
binaricat merged 13 commits into
mainfrom
ai/issue-3408-35052760130
Sep 18, 2026
Merged

binaricat merged 13 commits into
mainfrom
ai/issue-3408-35052760130

Conversation

@netcatty-bot

@netcatty-bot netcatty-bot commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

On macOS, Command-period now interrupts the connected terminal through the existing Ctrl+C path. It also works with broadcast terminals while preserving independent held keys and non-QWERTY keyboard layouts.

Type of Change

  • New feature
  • Bug fix

Related Issue (optional)

Closes #3408

Changes Made

  • Recognize Command-period on macOS, including layouts where Shift produces the logical period, including when output is selected, while giving user-configured snippet/app shortcuts precedence.
  • Reuse the existing urgent interrupt and input cleanup behavior.
  • Pair the normalized Ctrl+C press separately from physical C/Period presses. Release the saved normalized event without re-reading keyboard-layout metadata, then process the original physical release independently.
  • Preserve broadcast pairing across reconnects and focus-loss cleanup.
  • Add a real Electron regression test covering held keys, non-QWERTY layout, Kitty/legacy/Win32 input modes, logical period on physical KeyC, Shift-produced period, and native Command-period interrupting an actual tail -f process.

Screenshots / Demo

On macOS, the native Electron Command-period input stopped tail -f /dev/null in a real /bin/sh PTY. A subsequent command executed successfully. The shell test uses output markers absent from the echoed input to prevent false positives. No visual layout changes.

Testing

  • Tested locally with a visible Electron terminal (node_modules/.bin/electron scripts/terminal-command-period.live.test.cjs); full app npm run dev was not used.
  • Linting passes (npm run lint); the new live test also passes explicit eslint --no-ignore.
  • Relevant tests pass: 975 terminal runtime tests with concurrency limited to 4; after the layout follow-up, all 67 affected runtime/shortcut/broadcast tests pass.
  • Single clean full npm test run locally: initial run passed 12,030, skipped 28, failed 31 because the isolated checkout lacked a nested plugin dependency and default concurrency caused timeouts. After restoring the dependency, all 282 tests in the failed files passed with concurrency limited to 2. No unrelated product code was changed.
  • Generated capability tool specs: not applicable.
  • The final Electron verification explicitly asserts zero renderer errors.

The same Electron regression against the previous PR head fails the non-QWERTY release assertion, and the selection case fails before the selection fix; it passes against this revision. Native Win32 encoding was exercised inside macOS Electron, not against a Windows host.

Checklist

  • My code follows the existing project style
  • Relevant behavior and validation are documented above
  • No breaking changes

@netcatty-bot netcatty-bot added automation:bot-pr PR created or owned by Cursor automation automation:codex-loop Own/bot PR waiting on Codex review↔fix loop triage Touched by Cursor automation labels Sep 16, 2026
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-18T04:34:15.657895Z f2c2295 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a0ef88c085

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts Outdated
@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Sep 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 789a5ef2ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts
@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Sep 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 671ce69519

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts Outdated
@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Sep 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

upsertKittyKeyboardForwardedPress(
kittyForwardedKeys,
identity,
kittyEvent,
[],

P2 Badge Keep normalized interrupt presses separate from physical KeyC

When a Kitty release-reporting session already has the physical C key held, pressing Command+Period upserts the normalized interrupt under the same KeyC entry and replaces that outstanding press (the broadcast map has the same collision). The Period keyup then releases and deletes this shared entry while physical C is still down, and the eventual C keyup has no press to pair with, producing premature or modifier-mismatched releases in report-all TUIs. The new alias deletion only fixes a later stale Period keyup; it does not prevent this simultaneous identity collision, so the normalized press needs independently keyed/stacked bookkeeping.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Sep 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

const forwarded = broadcastKittyInput({ kind: "key", event: kittyEvent });

P2 Badge Carry the dedicated identity through broadcast pairing

With input broadcasting enabled, holding a physical C key and then pressing Command-period still collapses both presses on each peer because this dispatch sends only the normalized event whose code is KeyC; the new pressIdentity exists solely in the source-side maps, while resolveKittyKeyboardBroadcastInput() keys peer state from input.event.code. On a legacy peer the outstanding C entry can suppress the following urgent \x03 as duplicate, and on a Kitty peer the first release clears the shared pairing entry. Fresh evidence after the local alias fix is that no distinct correlation identity crosses this broadcast call, so it must be propagated and used by peer pairing.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts
Comment thread components/terminal/runtime/createXTermRuntime.ts Outdated
@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Sep 16, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 15f209d24d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts
@netcatty-bot netcatty-bot added ready-for-human Requires human implementation and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Sep 16, 2026
Repository owner deleted a comment from binaricat Sep 16, 2026
@binaricat
binaricat marked this pull request as ready for review September 18, 2026 03:43

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4291adbdfc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts Outdated
Comment thread components/terminal/runtime/terminalInterruptShortcut.ts
@binaricat

Copy link
Copy Markdown
Owner

@codex review

Please review the current head a3abb8f979c5565af0a31a316404171c6741dbc1. The selection finding is fixed and reproduced by the real Electron regression; the helper comment now uses ASCII. Both local independent reviewers report CLEAN at this head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a3abb8f979

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts Outdated
@binaricat

Copy link
Copy Markdown
Owner

@codex review

All newly added comments and test titles now use ASCII. Non-Latin layout test values retain the same characters using Unicode escapes. The complete PR diff has zero non-ASCII added lines; 66 affected tests and lint pass. Please review the latest head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b9f9dbea88

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread scripts/terminal-command-period.live.test.cjs Outdated
@binaricat

Copy link
Copy Markdown
Owner

@codex review

The live fixture now supplies resizeSession and supports raw broadcast data like TerminalLayer. It also collects renderer error messages and asserts none occurred. The complete real Electron test passes, including native Command-period stopping tail and a subsequent shell command. Please review the latest head.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d60972fdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/createXTermRuntime.ts
@binaricat binaricat added automation:codex-loop Own/bot PR waiting on Codex review↔fix loop and removed ready-for-human Requires human implementation labels Sep 18, 2026
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@binaricat
binaricat marked this pull request as draft September 18, 2026 04:18
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 8d60972fdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@binaricat
binaricat marked this pull request as ready for review September 18, 2026 04:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8d60972fdd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/runtime/terminalInterruptShortcut.ts Outdated
Comment thread components/terminal/runtime/createXTermRuntime.ts
@binaricat

Copy link
Copy Markdown
Owner

@codex review

Both layout findings are reproduced and fixed on the new head. Shift is accepted only when it produces the logical period; the physical fallback remains unshifted. Every normalized Command-period uses a dedicated identity and release alias, including when the original physical key is KeyC. All 67 affected tests pass; real Electron cases for both layouts, selected text, broadcasting, and native tail interruption pass with zero renderer errors.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: f2c2295b1a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Repository owner deleted a comment from binaricat Sep 18, 2026
@netcatty-bot netcatty-bot added automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Sep 18, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator Author

Codex reported no major issues. This PR is marked ready for human review/merge.

@binaricat
binaricat merged commit 0d21e37 into main Sep 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation:bot-pr PR created or owned by Cursor automation automation:codex-clean Last Codex review reported clean triage Touched by Cursor automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 将Mac 常用的 Command+. 中断执行映射为 CTRL+C

2 participants